from selenium.webdriver.support.ui import WebDriverWait

class Base():
    def __init__(self,dr):
        self.dr=dr
    def get_url(self,url):
        self.dr.get(url)
    def find_element(self,loc):
        try:#显示等待执行20秒每次0.5秒找一次
            WebDriverWait(self.dr,20,0.5).until(lambda dr:self.dr.find_element(*loc).is_displayed())
            return self.dr.find_element(*loc)
        except Exception as e:
            print(e)
    def send_keys(self,loc,info):
        self.find_element(loc).send_keys(info)
    def click(self,loc):
        self.find_element(loc).click()
    def test(self,loc):
        return self.find_element(loc).text
    def implicitly_wait(self,loc):
        #隐式等待寻找到关闭等待
        self.dr.implicitly_wait(loc)